<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{% block title %}{% endblock %}-白白博客</title>
    <link rel="stylesheet" href="{% static 'bootstrap5/bootstrap.min.css' %}">
    <script src="{% static 'bootstrap5/popper.min.js' %}"></script>
    <script src="{% static 'bootstrap5/bootstrap.min.js' %}"></script>
    <link rel="stylesheet" href="{% static 'css/base.css' %}">
    {% block head %}{% endblock %}
</head>
<body>
<header class="p-3 text-bg-warning border-bottom mb-3">
    <div class="container">
        <div class="d-flex flex-wrap align-items-center justify-content-center justify-content-lg-start">
            <!-- 博客Logo -->
            <a href="/" class="d-flex align-items-center mb-2 mb-lg-0 text-white text-decoration-none">
                <img src="{% static 'image/baibai.png' %}" alt="白白博客" width="40" height="40" class="me-2">
                <span class="fs-5 fw-bold">白白博客</span> <!-- 增加博客名称 -->
            </a>

            <!-- 导航链接 -->
            <ul class="nav col-12 col-lg-auto me-lg-auto mb-2 justify-content-center mb-md-0">
                <li><a href="/"
                       class="nav-link px-3 py-2 text-white hover:text-light bg-opacity-10 hover:bg-opacity-20 rounded">首页</a>
                </li>
                <li><a href="{% url 'blog:pub_blog' %}"
                       class="nav-link px-3 py-2 text-white hover:text-light bg-opacity-10 hover:bg-opacity-20 rounded">发布博客</a>
                </li>
                {% if user.is_authenticated %}
                    <li><a href="{% url 'baiauth:profile' %}"
                           class="nav-link px-3 py-2 text-white hover:text-light bg-opacity-10 hover:bg-opacity-20 rounded">个人简介</a>
                    </li>
                {% endif %}
            </ul>
            
            <!-- 搜索框 -->
            <form class="col-12 col-lg-auto mb-3 mb-lg-0 me-lg-3" role="search" action="{% url 'blog:search' %}"
                  method="GET">
                <input type="search" name="q" class="form-control form-control-dark text-bg-secondary border-0"
                       placeholder="搜索..." aria-label="Search" style="border-radius: 20px;">
            </form>

            {% if user.is_authenticated %}
                <div class="dropdown text-end"><a href="#"
                                                  class="d-block link-body-emphasis text-decoration-none dropdown-toggle"
                                                  data-bs-toggle="dropdown" aria-expanded="False"> <img
                        src="{{ user.profile.avatar.url }}" alt="用户头像" width="32" height="32" class="rounded-circle">
                </a>
                    <ul class="dropdown-menu text-small" data-popper-placement="top-start"
                        data-popper-reference-hidden=""
                        style="position: absolute; inset: auto auto 0px 0px; margin: 0px; transform: translate3d(-40px, -33.6px, 0px);">
                        <li><a class="dropdown-item" href="{% url 'baiauth:logout' %}">退出登录</a></li>
                    </ul>
                </div>
            {% else %}
                <div class="text-end">
                    <a href="{% url 'baiauth:login' %}" type="button" class="btn btn-outline-dark me-2">登录</a>
                    <a href="{% url 'baiauth:register' %}" type="button" class="btn btn-dark">注册</a>
                </div>
            {% endif %}
        </div>
    </div>
</header>
<main class="container bg-white p-3 rounded">
    {% block main %}{% endblock %}
</main>
</body>
</html>